﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SHKF.B2C.JuShuiTan.Model;
using SHKF.B2C.JuShuiTan.Model.Inter.ShopQuery;
using SHKF.B2C.JuShuiTan.Network;
using SHKF.B2C.Model.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SHKF.B2C.JuShuiTan.Service.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class ShopController : BaseController
    {
        public ShopController(IServiceProvider serviceProvider, ILogger<ShopController> logger) : base(serviceProvider, logger)
        {

        }


        [HttpPost("List")]
        public async Task<BaseDto> List(ShopsQueryParam data)
        {
            BaseDto dto = new BaseDto();
            try
            {
                BaseDto dto2 = this.GetCompanyID();
                if (dto2.code == -1)
                {
                    dto = new BaseDto();
                    dto.code = -1;
                    dto.msg = dto2.msg;

                    return dto;
                }
                else
                {
                    this.httpClient.CompanyID = dto2.msg;

                }

                dto = await this.httpClient.ShopsQuery(data);
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex.Message);
            }

            return dto;
        }
    }
}
